home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / p_man / cat3 / f90 / index.z / index
Text File  |  1998-10-30  |  4KB  |  93 lines

  1. INDEX(3I)                                              Last changed: 1-6-98
  2.  
  3.  
  4. NNAAMMEE
  5.      IINNDDEEXX - Determines the starting location of a character substring in a
  6.      string
  7.  
  8. SSYYNNOOPPSSIISS
  9.      IINNDDEEXX (([SSTTRRIINNGG==]_s_t_r_i_n_g,, [SSUUBBSSTTRRIINNGG==]_s_u_b_s_t_r_i_n_g [,,[BBAACCKK==]_b_a_c_k]))
  10.  
  11. IIMMPPLLEEMMEENNTTAATTIIOONN
  12.      UNICOS, UNICOS/mk, and IRIX systems
  13.  
  14. SSTTAANNDDAARRDDSS
  15.      Fortran 90
  16.  
  17. DDEESSCCRRIIPPTTIIOONN
  18.      The IINNDDEEXX intrinsic function returns the starting position of a
  19.      substring within a string from either the right or left end of the
  20.      string.  It accepts the following arguments:
  21.  
  22.      _s_t_r_i_n_g    Must be of type character.
  23.  
  24.      _s_u_b_s_t_r_i_n_g Must be of type character.
  25.  
  26.      _b_a_c_k      Must be of type logical.  If omitted, a value of false is
  27.                assumed.  If present, the search begins at the end of
  28.                _s_t_r_i_n_g.
  29.  
  30.      IINNDDEEXX is an elemental function.  The name of this intrinsic can be
  31.      passed as an argument.
  32.  
  33. NNOOTTEESS
  34.      When the IINNDDEEXX intrinsic function is passed as an actual argument, it
  35.      must be called with only the first two arguments in the routine that
  36.      calls the passed-in function.
  37.  
  38. RREETTUURRNN VVAALLUUEESS
  39.      The _b_a_c_k argument can affect the return value as follows:
  40.  
  41.      * If _b_a_c_k is absent or is present with the value FFAALLSSEE, the IINNDDEEXX
  42.        search is relative to the left end of _s_t_r_i_n_g.  The result is the
  43.        minimum positive value of _i, as follows:
  44.  
  45.           _s_t_r_i_n_g (( _i :: _i ++ LLEENN(( _s_u_b_s_t_r_i_n_g )) -- 11 )) == _s_u_b_s_t_r_i_n_g
  46.  
  47.        If the length of _s_u_b_s_t_r_i_n_g is 0, a value of 1 is returned.
  48.  
  49.      * If _b_a_c_k is present with the value TTRRUUEE, the IINNDDEEXX search is relative
  50.        to the right end of _s_t_r_i_n_g.  The result is the maximum positive
  51.        value of the following:
  52.  
  53.           _i <<== LLEENN(( _s_t_r_i_n_g )) -- LLEENN(( _s_u_b_s_t_r_i_n_g )) ++ 11
  54.  
  55.        In the preceding equation, _s_u_b_s_t_r_i_n_g is as follows:
  56.  
  57.           _s_t_r_i_n_g (( _i :: _i ++ LLEENN(( _s_u_b_s_t_r_i_n_g )) -- 11 )) == _s_u_b_s_t_r_i_n_g
  58.  
  59.        If the length of _s_u_b_s_t_r_i_n_g is 0, the value returned is as follows:
  60.  
  61.           LLEENN(( _s_t_r_i_n_g )) ++ 11.
  62.  
  63.      If _s_u_b_s_t_r_i_n_g occurs more than once in _s_t_r_i_n_g, IINNDDEEXX returns the index
  64.      to the first occurrence.
  65.  
  66.      The return value is 0 if _s_u_b_s_t_r_i_n_g is not located within _s_t_r_i_n_g.
  67.  
  68.      The return value is 0 if the length of _s_t_r_i_n_g is less than the length
  69.      of _s_u_b_s_t_r_i_n_g.
  70.  
  71. EEXXAAMMPPLLEESS
  72.      Example 1:  IINNDDEEXX((''FFOORRTTRRAANN'',,''RR'')) has the value 3.
  73.  
  74.      Example 2:  IINNDDEEXX((''FFOORRTTRRAANN'',,''RR'',,BBAACCKK==..TTRRUUEE..)) has the value 5.
  75.  
  76.      Example 3:  The following program returns the index II==1111 for the
  77.      substring SSUUPPEERRCCOOMMPPUUTTEERR:
  78.  
  79.           PROGRAM INDEX1
  80.           CHARACTER*23 A
  81.           CHARACTER*13 B
  82.           A = 'CRAY T90 SUPERCOMPUTER'
  83.           B = 'SUPERCOMPUTER'
  84.           I = INDEX(A,B)
  85.           PRINT *, I
  86.           STOP
  87.           END
  88.  
  89. SSEEEE AALLSSOO
  90.      _I_n_t_r_i_n_s_i_c _P_r_o_c_e_d_u_r_e_s _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, publication SR-2138, for the
  91.      printed version of this man page.
  92.  
  93.